<?php
	$loi = "";
	if(isset($_POST["ok"])){
		$x = $img = $g = "";
		if($_POST["xe"] == null){
			$loi[] = "Chua nhap ten xe";
		}else{
			$x = $_POST["xe"];
		}
		if($_POST["gia"] == null){
			$loi[] = "Chua nhap gia";
		}else{
			$g = $_POST["gia"];
		}
		if($_FILES['img']['name'] != ""){
			$upload=new Upload($_FILES["img"]);
			if($upload->do_upload() == TRUE){
				$upload->do_upload();
				$img="upload/".$_FILES["img"]["name"];
			}
		}
		$duyet = $_POST["kiemduyet"];
		$hang = $_POST["hang"];
		$loai = $_POST["loai"];
		$u = $_SESSION["se_id"];
		$tt = $_POST["tt"];
		if(isset($u)){
			if($x && $img && $duyet && $hang && $loai && $tt){
				$xe = new mxe();
				$xe->setxe($x);
				$xe->sethinhanh($img);
				$xe->setkiemduyet($duyet);
				$xe->sethang($hang);
				$xe->setloai($loai);
				$xe->setuser($u);
				$xe->settrangthai($tt);
				$xe->setgia($g);
				$xe->add();
				header("location: index.php?module=xe&action=list");
				exit();
			}
		}else{
			echo "Ko ton tai";
		}
	}
?>
<?php
	require ("views/xe/vadd.php");
?>